package com.eostoken.eos_wallet.net.common;

import com.eostoken.eos_wallet.bean.AccountNames;
import com.eostoken.eos_wallet.bean.AppVersionBean;
import com.eostoken.eos_wallet.bean.EOSPrice;
import com.eostoken.eos_wallet.utils.Constants;
import com.google.gson.JsonObject;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface RequestApi {

    /**
     * 通过公钥获取账户名
     *
     * @param publickey
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("/v1/history/get_key_accounts")
    Observable<AccountNames> getKeyAccounts(@Body Map<String, Object> publickey);

    /**
     * 调用停用当前出块器。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/pause")
    Observable<String> getPause();

    /**
     * 调用返回当前出块器是否暂停。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/paused")
    Observable<String> getPaused();

    /**
     * 调用返回当前出块器的运行参数。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/get_runtime_options")
    Observable<String> getRuntimeOptions();

    /**
     * 调用可以修改出块运行参数。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/update_runtime_options")
    Observable<String> getUpdateRuntimeOptions(@Body RequestBody requestBody);

    /**
     * 调用返回出块灰名单。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/get_greylist")
    Observable<String> getGreylist();

    /**
     * 调用向出块灰名单中添加指定的账号。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/add_greylist_accounts")
    Observable<String> getAddGreylistAccounts(@Body RequestBody requestBody);

    /**
     * 调用从出块灰名单中删除指定的账号。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/remove_greylist_accounts")
    Observable<String> getRemoveGreylistAccounts(@Body RequestBody requestBody);

    /**
     * 调用返回当前应用的出块白名单和黑名单。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/get_whitelist_blacklist")
    Observable<String> getWhitelistBlacklist();

    /**
     * 调用设置出块白名单和黑名单。
     *
     * @return
     */
    @Headers("urlname:" + Constants.EOS_URL)
    @POST("v1/producer/set_whitelist_blacklist")
    Observable<String> setWhitelistBlacklist();

    /**
     * 去交易所获取数字货币价格
     *
     * @param pair 数字货币类型_货币单位 如：EOS_USDT EOS兑换美元的价额
     * @return
     */
    @Headers("urlname:" + Constants.EXCHANGE_URL)
    @GET("/v1/q/ticker/price")
    Observable<EOSPrice> getDIGICCYPrice(@Query("pair") String pair);

    /**
     * @param appType 1:Android 固定值
     * @param type    1：当前app 固定值
     * @return
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @FormUrlEncoded
    @POST("/api/appVersion/getVersion")
    Observable<JsonObject> getVersion(@Field("appType") String appType,
                                      @Field("type") String type);

    /**
     * @param content content
     * @return
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/findMgp")
    Observable<JsonObject> getFindMgp(@Header("content") String content);

    /**
     * @param content accountName
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/orderIndex")
    Observable<JsonObject> getOrderIndex(@Header("content") String content);

    /**
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/realTimeIndex")
    Observable<JsonObject> getRealTimeIndex();


    /**
     * @param content accountName
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/mortgage")
    Observable<JsonObject> getMortgageAssociation(@Header("content") String content);

    /**
     * @param content accountName
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/bindMgp")
    Observable<JsonObject> getBindMidMgp(@Header("content") String content);

    /**
     * @param content accountName
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/nodeIndex")
    Observable<JsonObject> getNodeIndex(@Header("content") String content);

    /**
     * "address", address
     * "limit", "100"
     * "page", "1"
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/myOrderWallet")
    Observable<JsonObject> getMyOrderWallet(@Header("content") String content);

    /**
     * "address", address
     * "moneyType", moneyType
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/order/withdraw/withdrawIndex")
    Observable<JsonObject> getWithdrawIndex(@Header("content") String content);

    /**
     * "address", address
     * "moneyType", moneyType
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/order/withdraw/addOrder")
    Observable<JsonObject> getWithdrawAddOrder(@Header("content") String content);

    /**
     * "address", address
     * "limit", "100"
     * "page", "1"
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/user/indexMarkIndex")
    Observable<JsonObject> getIndexMarkIndex(@Header("content") String content);

    /**
     * "currentAddr", address
     * "type", "2";1:ETH,2:MGP
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/userTransactionRecord/checkstatus")
    Observable<JsonObject> getBindWalletAddress(@Header("content") String content);

    /**
     * "bindAddr", address
     * "type", "2";1:ETH,2:MGP
     * "currentAddr", address
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/userTransactionRecord/add")
    Observable<JsonObject> bindWalletAddress(@Header("content") String content);

    /**
     * "bindAdress", bindAdress
     * "type", "2";1:ETH,2:MGP
     * "address", address
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/userTransactionRecord/checkAddr")
    Observable<JsonObject> checkAddr(@Header("content") String content);

    /**
     * "address", bindAdress
     * "type", "2";1:ETH,2:MGP
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("/userTransactionRecord/find")
    Observable<JsonObject> isFindMIDBinding(@Header("content") String content);

    /**
     * 云矿机收益明细
     * "address", string
     * "limit", "100"
     * "page", "1"
     *
     * @param content content
     * @return
     * @Header("content:") String content
     */
    @Headers("urlname:" + Constants.CORPORATION_URL)
    @POST("order/miningOrderIncome")
    Observable<JsonObject> getMiningOrderIncome(@Header("content") String content);
}
